import { useRef } from 'react';
import { YmBackTop } from 'ym-design';

const YmBackTopDemo = () => {
  const contentRef = useRef<HTMLDivElement>(null);
  return (
    <div
      style={{
        width: '100%',
        height: '400px',
        overflowY: 'auto',
        position: 'relative',
      }}
      ref={contentRef}
    >
      <div style={{ width: '100%', height: '600px' }}></div>
      {contentRef.current && (
        <YmBackTop
          visibilityHeight={100}
          target={contentRef.current!}
          backTopStyle={{ position: 'absolute' }}
        />
      )}
    </div>
  );
};

export default YmBackTopDemo;
